<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>

<sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
    select * From Docentes
    where situacao=''
    and exists(select 1 from Competencias_Docentes d
    inner join Componentes_Competencias c on d.id_competencia=c.id_competencia
    where d.matricula=Docentes.matricula
    <c:if test="${!empty param.id_componente}">
        and c.id_componente=?
    </c:if>
    )
    order by NOME
    <c:if test="${!empty param.id_componente}">
        <sql:param value="${param.id_componente}"/>
    </c:if>
</sql:query>
<c:choose>
    <c:when test="${!empty query.rows}">
        <label class="lbInput">Docentes<em>*</em></label>
        <select id="matricula" name="matricula" class="required">
            <option value="">Selecione um docente</option>
            <c:forEach var="row" items="${query.rows}">
                <option value="${row.matricula}" ${row.matricula==param.matricula?'selected':''}>${row.NOME} - ${row.horario} </option>
            </c:forEach>
        </select>
        <script>
            $(function() {
                $("#matricula").change(function(){
                    if ($(this).val()!='') {
                        $('#gerar').show();
                    }
                    else {
                        $('#gerar').hide();
                    }
                });
            });
        </script>
    </c:when>
    <c:otherwise>
        <p style="font-size: 12pt; color: red">Nenhum docente foi encontrado para o componente.</p>
    </c:otherwise>

</c:choose>

